{% extends 'base.html' %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block title %}{{ view_title }} - {{ block.super }}{% endblock %}

{% block content %}
<h1>
    {{ view_title }}
    {% if selected_field %}
        <small class="text-muted fs-5">({% trans "为田块" %}: {{ selected_field.name }})</small>
    {% endif %}
</h1>

<div class="card shadow-sm">
    <div class="card-body">
        <form method="post" novalidate>
            {% csrf_token %}
            {{ form|crispy }}

            <div class="mt-4">
                <button type="submit" class="btn btn-primary"><i class="bi bi-check-circle"></i> {% trans "保存记录" %}</button>
                {% if object %} {# Editing: Link back to record detail #}
                    <a href="{{ object.get_absolute_url }}" class="btn btn-secondary"><i class="bi bi-x-circle"></i> {% trans "取消" %}</a>
                {% elif selected_field %} {# Adding for specific field: Link back to field detail #}
                     <a href="{{ selected_field.get_absolute_url }}" class="btn btn-secondary"><i class="bi bi-x-circle"></i> {% trans "取消" %}</a>
                {% else %} {# General adding: Link back to record list #}
                    <a href="{% url 'planting_records:record_list' %}" class="btn btn-secondary"><i class="bi bi-x-circle"></i> {% trans "取消" %}</a>
                {% endif %}
            </div>
        </form>
    </div>
</div>
{% endblock %}

{% block extra_js %}
{# Add JS for date pickers or other enhancements if needed #}
{% endblock %}